<?php 
    require_once("include/game_core.php");
    require_once(VIEW_BASE_FILE);  
    require_once (GAME_TABLE_FILE);
    $view = new view_base();
    $view->ShowHeader();
    $view->ShowMenu("stats");
    $view->ShowConatinerHead();
    
    $lastGames =  GameTable::getLastPlayedGamesAndAvatars();
?>
<div id="content">
    <table width="100%">
        <tr>
            <td><h2>Recent battles</h2></td>
        </tr>
    </table>
    <h3>Take notes..</h3>
    <br/>

    <table width="100%">
        <tr>
            <?php
                echo '<table width="100%" border ="1">';
                echo '<tr><th>Date</th><th>Duration</th><th>Moves</th><th>Winner</th><th></th><th></th><th>Loser</th><tr>';               
                if($lastGames != null) {
                    while($row = $lastGames->fetch_assoc()) {
                        echo '<tr>
                            <td>' . $row['date'] . '</td>
                            <td>' . $row['duration'] . '</td>
                            <td>' . $row['moves'] . '</td>
                            <td>' . $row['win_nick'] . '</td>';
                            ?><td><img src="images/avatars/<?php echo $row['win_avatar'];  ?>.png" height="20" width="20"></td>
                            <td><img src="images/avatars/<?php echo $row['lost_avatar'];  ?>.png" height="20" width="20"></td><?php	
                        echo '<td>' . $row['lost_nick'] . '</td>';
                    }
                }
                echo '</table>';
            ?>
        </tr>
    </table>

</div>
<?php include (VIEW_SIDE_FILE); ?>
<?php   $view->ShowFooter();      ?>